////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    TripleToucan.h                                               //
//  Developer:   Marilyn Bolanos                                              //
//  Create date: 09/11/2007                                                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called TripleToucan.                 //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2007 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#if !defined(__TRIPLETOUCANGUTS_H__)
#define __TRIPLETOUCANGUTS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"

class TripleToucanGuts : public SlotGuts
{
public:
	TripleToucanGuts();

	virtual ~TripleToucanGuts();

private:
	// Shared enums between client and server
	#include "TripleToucanCommon.h"

    // Typedef for our base class
	typedef SlotGuts super;

	// Helpful lookup arrays.
    // Array to look for winning spin
	static SpinResult m_aLineWinSpinResults[][6];
    // Array to look for scatter win spin
	static SpinResult m_aScatterWinSpinResults[6];


	// Inline function that looks the event related to the nCount number of nIconType icons.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

    // Inline function that looks the event related to the nCount number of scatters.
	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

    void tryForJackpot( SlotSpin* spin );
    
    // Helper functions for classifyStops.
    SpinResult getToucanLineWinResult( uint8* stops ) const;
	SpinResult getLineWinResultWithPossibleSubstitution(
		uint8* stops, uint8 testIcon, bool& bSubstitution ) const;
    bool doesToucanLineWinPayMore( SpinResult srToucan, SpinResult srOther,
		bool bSubstitution ) const;


	// Helper functions for classifyScatters.
	SpinResult getScatterWinResult( SlotSpin* spin, int32& nNumScatterIcons, int32& nScatterPositions) const;
	void addScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 nScatterPositions);
	void addFeatureTrigger( SlotSpin* spin, int32& nNumScatterIcons, int32 nFeatureScatterPositions );

public:
	virtual void classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnresult, uint8& multiplier );

	virtual void classifyScatters( SlotSpin *spin );

    virtual bool8 isValidGuts();

protected:
    // Helper member for the toucan expands across the entire reel behavior
    typedef std::map<const SlotIcon*, SlotIcon*> SlotIconSubstitutionMap;
	bool8 m_bAllowToucanIconSubstitutions;
	SlotIconSubstitutionMap	m_mapSubstitutionIcons;

    // Helper functions for the toucan expands across the entire reel behavior
	bool8 allocateToucanSubstitionIcons();
    void deallocateToucanSubstitutionIcons();
    void addSubstitutionIcon( const SlotIcon* current );
    bool8 getToucanIconOnReel( uint8 nReel ) const;
	void  setToucanIconOnReel( uint8 nReel, bool8 substitute );
	void  clearToucanIconSubstitutions();
    virtual void preSpinClassifyResults( SlotSpin *spin );

    // Overrides of the framework function for the toucan expands across the entire reel behavior.
    const SlotIcon* getIcon( uint8 gamemodeID, uint8 reelID, uint8 position ) const;
    virtual bool8 load( Info* info );

    // Helper function for debug mode
	virtual void Debug_SetLoserStops( uint8* pStops );

};


#endif // !defined(__TRIPLETOUCANGUTS_H__)
